package com.example.androidproject.movie.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.androidproject.R;

import java.util.ArrayList;
import java.util.List;

public class ChannelAdapter extends BaseAdapter {
    private final String TAG = "GGSTUDY";
    private final List<String> textList;
    private final Context mContext;

    public ChannelAdapter(Context mContext, List<String> textList) {
        this.mContext = mContext;
        this.textList = textList;
    }

    @Override
    public int getCount() {
        return textList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_channel, null);
            viewHolder = new ViewHolder();
            viewHolder.textView = convertView.findViewById(R.id.tv_channel);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.textView.setText(textList.get(position));
        return convertView;
    }

    static class ViewHolder {
        TextView textView;
    }
}
